package service

import (
	"bms/dao"
	"bms/model"
)

func GetBorrowItem(bookId int64, borrowId string) (*model.BorrowItem, error) {
	borrowItem, err := dao.GetBorrowItem(bookId, borrowId)
	if err != nil {
		return nil, err
	}
	return borrowItem, nil
}
func UpdateBorrowItemNums(borrowItem *model.BorrowItem) error {
	err := dao.UpdateBorrowItemNums(borrowItem)
	if err != nil {
		return err
	}
	return nil
}

func SaveBorrowItem(borrowItem *model.BorrowItem) error {
	err := dao.SaveBorrowItem(borrowItem)
	if err != nil {
		return err
	}
	return nil
}

func ReturnBookByBorrowItemId(borrowItemId int64) error {
	err := dao.ReturnBookByBorrowItemId(borrowItemId)
	if err != nil {
		return err
	}
	return nil
}

func QueryBorrowItem(borrowItemId int64) bool {
	b := dao.QueryBorrowItem(borrowItemId)
	if b {
		return true
	}
	return false
}
